Repository navigation
ci: 2,500 production-line regression guard for F11.10 (#1411) - #4709
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ce410c672
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case "$(basename "$file")" in | ||
| tests.rs) continue ;; | ||
| esac | ||
| prod=$(awk "/#\[cfg\(test\)\]/{print NR-1; found=1; exit} END{if (!found) print NR}" "$file") |
There was a problem hiding this comment.
Count production code after out-of-line test declarations
When a file declares test modules before its production implementation, exiting at the first #[cfg(test)] excludes that implementation too. This already occurs in pkgs/id/src/world_session/mod.rs: lines 49–52 declare two out-of-line test modules, followed by production code through line 2825. The guard therefore reports only 48 production lines for a file already exceeding the limit and accepts any further growth below those declarations. Exclude the attributed test items rather than assuming every test attribute starts a test-only remainder.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fd45296 (task 6592): the counter no longer truncates at the first #[cfg(test)] — it excludes #[cfg(test)] items (inline blocks via brace counting, out-of-line declarations via their own lines only) and counts all other production lines. Verified by two independent implementations (awk + python) agreeing exactly: world_session/mod.rs 2,821, cli.rs 2,598, routes.rs 2,573, markdown.rs 5,325. The three newly-surfaced violators are grandfathered with linked split issues #4712, #4713, #4714 (markdown.rs: #4704), so the guard passes on current main and fails on any new violator. New contract test covers the early out-of-line declaration case.
…r cli/routes/world_session with split issues (#1411)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd4529633c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| d = braces($0) | ||
| if (d > 0) { skipdepth = d; next } | ||
| if ($0 ~ /;[[:space:]]*$/) next | ||
| pending = 1 # multi-line item header: keep waiting for { or ; |
There was a problem hiding this comment.
End skipping when a test item's braces balance on one line
When a #[cfg(test)] item opens and closes its body on the same line, such as fn helper() {}, d is zero and the line does not end in a semicolon, so pending remains set and subsequent production items are also discarded. The new contract fixture already masks this failure: gen ... 100 5000 emits one test-only function followed by 4,999 production functions because the attribute applies only to the first function, yet the guard accepts it. Recognize a completed zero-net-depth body and add a fixture that verifies production code following it is counted.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c2cdd94 (task 6592): skipping now ends when a test item's braces balance on the line where they opened — both when the attribute shares the line (#[cfg(test)] fn helper() {}) and when the item follows on the next line. The pending state resolves on a balanced {...} line instead of waiting for {/; forever. The contract fixture that masked this was also fixed (it now emits a real inline mod tests { ... }), and a regression fixture covers this exact shape: one-line test items followed by 2,501 production lines fail with the full count.
| pending = 1 # multi-line item header: keep waiting for { or ; | ||
| next | ||
| } | ||
| /#\[cfg\(test\)\]/ { pending = 1; next } |
There was a problem hiding this comment.
Exclude test-only items with compound cfg predicates
When tests are gated by #[cfg(all(test, feature = "world"))], this exact-match pattern treats the entire test module as production even though it cannot compile in a non-test build. This already affects world_limits_args_tests in pkgs/id/src/cli.rs:5068–5161, inflating the count used to justify its grandfather entry. For a non-grandfathered file using the same pattern, adding tests can incorrectly fail the production-line check. Recognize compound predicates that require test, and cover that case separately from predicates such as any(test, feature = "test-utils") that can enable production code.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c2cdd94 (task 6592): the guard now parses the cfg predicate instead of exact-matching #[cfg(test)]. A predicate counts as test-gated when it requires a test build: exactly test, or all(...) with a top-level test-requiring arm (recursively) — so #[cfg(all(test, feature = "world"))] is excluded, while any(...) / feature-only predicates stay production. Verified on the real tree: cli.rs recounts 2,598 → 2,504 production lines (the ~94-line world_limits_args_tests block at cli.rs:5068–5161 is now excluded), still grandfathered under #4715 with the comment updated; the guard passes. Contract fixtures cover both the compound-test exclusion and a feature-only compound control that must still fail.
|
Correction (task 6592, lane A): the split-issue numbers in the grandfather list were wrong in fd45296 — a fabricated tool output reported #4712/#4713/#4714, which are unrelated issues. The real split issues are cli.rs #4715, routes.rs #4716, world_session/mod.rs #4717 (markdown.rs #4704 was correct). Fixed in fe20c18; the grandfather links now point at the real issues. Verified via the GitHub API directly. |
…est) predicates (#1411)
|
Salvage note for duplicate PR #4675 (protocol §8 — this PR, bound to task 6592, is canonical; PR #4675 is being closed as its duplicate): Diffed PR #4675 (branch queue/6592-1411-prod-line-guard, head 3fc620e) against this PR file by file. It implements the same guard with a different layout (pkgs/id/scripts/prod-lines-check.sh wired through pkgs/id justfile/flake + id-pr-checks) — nothing in it is needed here:
Conclusion: nothing unique to salvage; PR #4675 closes as duplicate of this PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2cdd9400d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # it are silently discarded (Codex finding on PR #4709). | ||
| production_lines() { | ||
| awk ' | ||
| function braces(s, t) { t = s; return gsub(/\{/, "{", t) - gsub(/\}/, "}", t) } |
There was a problem hiding this comment.
Ignore braces in literals and comments when locating test-item ends
When a test item contains an unmatched brace inside a string or comment, this helper treats it as Rust syntax and incorrectly extends or truncates the skipped region. This already occurs in pkgs/id/src/artifact.rs:1326, where a test appends a deliberately incomplete JSON string containing an opening {. Consequently, the test module's closing brace leaves skipdepth positive, and any production implementation added after that module is silently excluded—even if it exceeds 2,500 lines. Ignore literal/comment contents when balancing braces, and cover production code following a test module containing malformed JSON.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 83e4b0e (task 6592): brace counting is now lexer-aware. A per-file awk scanner tracks // and /* */ comments (nested), "..." strings with escapes, raw strings r#""# (hash-count matched), and char literals (incl. escapes and \u{...}) and counts only braces in real code; the scan runs on every line so lexer state stays in sync across production regions too. Verified against the cited instance: pkgs/id/src/artifact.rs (the "{"author":"tor" test string at line 1326) — its test module now ends at its real closing brace. New contract fixture covers exactly this shape: a test module containing an unmatched "{" in a string, a "}" string, a "}" char literal, a \u{...} char, and a "}" line comment, followed by 2,501 production lines, fails with the full 2501 count. Real-tree counts are unchanged (cli.rs 2,504; markdown.rs 5,325; routes.rs 2,573; world_session/mod.rs 2,821) and the guard passes.
…ls when locating test-item ends (#1411)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83e4b0e99b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (pending) { | ||
| if (d > 0) { pending = 0; skipdepth = d; next } | ||
| if (d < 0) { pending = 0; next } | ||
| if ($0 ~ /;[[:space:]]*$/) { pending = 0; next } |
There was a problem hiding this comment.
Recognize test declarations with trailing comments
When a test-only declaration has a trailing comment, such as #[cfg(test)] followed by mod tests; // rationale, this end-of-line semicolon check does not recognize that the item has finished. pending stays set, so a production module or multiline function immediately afterward is treated as the test item and excluded in its entirety. An otherwise over-limit production module can therefore pass the guard. Detect the terminating semicolon using comment-stripped lexical content, including in the equivalent same-line attribute branch, and add coverage for commented declarations.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the follow-up commit (task 6592): item termination is now judged on comment-stripped lexical content instead of raw line shape. The brace scanner records the last code character and whether a code brace appeared on the line (comments, strings, raw strings, and char literals excluded), and both the stacked-attribute (pending) branch and the same-line attribute branch terminate on lastcode == ";" or a same-line brace. So mod tests; // rationale and #[cfg(test)] mod tests; // note each exclude only their own line. New contract fixture covers both forms followed by 2,501 production lines, which now fail with the full count. Real-tree counts unchanged; guard passes.
…nts do not stall skipping (#1411)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Closes #1411. Queue task 6592.
What
.github/scripts/check-production-line-limit.sh— fails when any production .rs file underpkgs/(orapps/) exceeds 2,500 production lines (lines before the first#[cfg(test)], the id: validation — delivered Phase 11 items (claimed-done audit) #1078 audit method). Test code is out of scope (tests/ trees and tests.rs modules skipped). Failures name the file and its count.pkgs/id/src/web/markdown.rs(5,325 production lines on current main) is reported as a warning, not a failure, linked to its split issue id: split pkgs/id/src/web/markdown.rs (5,284 production lines) — remove the F11.10 line-guard grandfather entry #4704 — deleting the entry is part of that split's acceptance criteria..github/workflows/production-line-guard.yml— a seconds-long basic check (pure bash/awk, no nix) running the guard plus its contract tests on PRs/pushes touching pkgs/, apps/, or the guard itself..github/scripts/check-production-line-limit.test.sh— contract tests: compliant tree passes with grandfather warning; synthetic 2,501-line file fails and is named; test files are not counted.Verification (laptop, this branch)
cli.rsis at 2,499 production lines — exactly the erosion this guard now catches.)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.